Music Object Extension - Group Volume

  Contents

About This Extension

The Group Volume extension provides methods for conveniently adjusting the overall volume of an entire group of Music Object instances. This, for example, makes it really easy for the overall group volume levels of all Music Object instances that are being used for one functional aspect of a page's sonification (such as user interface sound effects or background music) to be adjusted in one simple step, without interfering with the different instances' individual volume levels that are being used to balance the instances together in the group. In particular, this extension offers the Music.setPageVolume and Music.getPageVolume static methods that make it possible to modify the overall volume of a page's sonification in one operation.

What's New in the Latest Version

There is a dedicated version history for this extension, where you will be able to find out about the new features and possible issues with the most recent version. The version history for this extension is independent of the version history for the core Music Object API.

Getting This Extension

To get the "music-object-x-group-volume.js" JavaScript file that implements this extension, simply right-click on this link (click-and-hold for Mac users). Then, from the menu that pops up, select the 'Save Link As...' or 'Save Target As...' option and save the file as "music-object-x-group-volume.js" into an appropriate folder of the local copy of your Web site.

In case you have problems saving the file using the above link, the "music-object-x-group-volume.js" file can also be found inside the documentation's "javascript" folder, along with the "music-object.js" file.

Dependencies

In order to use this extension, the following JavaScript file(s) must first be sourced in...

For more information on using extensions, consult the section About Music Object Extensions.

Reference

 Name   Short Description 
Static Methods
Music.addVolumeGroupMembers Lets you add the specified Music Object instances as members to the specified volume group.
Music.destroyVolumeGroup Lets you destroy the specified volume group, effectively removing all of its members.
Music.fadeGroupVolume Lets you perform a volume fade on the specified volume group.
Music.fadePageVolume Lets you perform a fade of the page's volume, effectively fading all Music Object instances in the page.
Music.getGroupVolume Returns an integer value, indicating the volume level for the specified volume group.
Music.getPageVolume Returns an integer value, indicating the overall volume level for the page.
Music.removeVolumeGroupMembers Lets you remove the specified Music Object instance(s) from the specified volume group.
Music.setGroupVolume Lets you set the volume level for the specified volume group.
Music.setPageVolume Lets you set the overall page volume, affecting all Music Object instances in the page.

Static Methods

 Music.addVolumeGroupMembers

 
 CATEGORY   Static Method 
 MODULE   Music Object Extension - Group Volume 
 Min. Player Version   1.0.0 
 

The Music.addVolumeGroupMembers static method lets you add the specified Music Object instances as members to the specified volume group

SYNTAX    Music.addVolumeGroupMembers (
   GroupNameSTR ,
   GroupMembersARRAYorOBJ
)

Multiple Music Object instances can be added to a group - one at a time - by specifying the Music Object instance references in multiple calls to the Music.addVolumeGroupMembers method, as in the code...

Music.addVolumeGroupMembers ('My Volume Group',myMusicObject1);
Music.addVolumeGroupMembers ('My Volume Group',myMusicObject2);
Music.addVolumeGroupMembers ('My Volume Group',myMusicObject3);
Music.addVolumeGroupMembers ('My Volume Group',myMusicObject4);
Music.addVolumeGroupMembers ('My Volume Group',myMusicObject5);

Alternatively, by specifying an array for the GroupMembersARRAYorOBJ parameter, all the instances can be added in just one statement. A temporary array can be created inside the call to the Music.addVolumeGroupMembers method to contain all the Music Object instances, as in the code...

Music.addVolumeGroupMembers (
   'My Volume Group',
   new Array (
      myMusicObject1,
      myMusicObject2,
      myMusicObject3,
      myMusicObject4,
      myMusicObject5
   )
);

When adding members to a volume group, it doesn't matter in what order the members are added, over how many separate statements the members are added, or whether the members are added using arrays or single object references.

So, for example, the code...

Music.addVolumeGroupMembers ('My Volume Group',myMusicObject2);

Music.addVolumeGroupMembers (
   'My Volume Group',
   new Array (
      myMusicObject5,
      myMusicObject3,
      myMusicObject4
   )
);

Music.addVolumeGroupMembers ('My Volume Group',myMusicObject1);

...is equivalent to the code...

Music.addVolumeGroupMembers (
   'My Volume Group',
   new Array (
      myMusicObject1,
      myMusicObject2,
      myMusicObject3,
      myMusicObject4,
      myMusicObject5
   )
);

It also does not matter how many times a specific Music Object instance is added to a volume group. Any Music Object instance can only be a member of a group once. So, the following code still results in only five members being added to the volume group "My Volume Group"...

Music.addVolumeGroupMembers ('My Volume Group',myMusicObject1);

Music.addVolumeGroupMembers (
   'My Volume Group',
   new Array (
      myMusicObject1,
      myMusicObject2,
      myMusicObject3,
      myMusicObject4,
      myMusicObject5
   )
);

Music.addVolumeGroupMembers ('My Volume Group',myMusicObject3);

SPECIAL VALUES
VARIATIONS
 Music.destroyVolumeGroup

 
 CATEGORY   Static Method 
 MODULE   Music Object Extension - Group Volume 
 Min. Player Version   1.0.0 
 

The Music.destroyVolumeGroup static method lets you destroy the specified volume group, effectively removing all of its members.

SYNTAX    Music.destroyVolumeGroup ( GroupNameSTR )

The volume setting for a volume group that is being destroyed will cease to have any effect on the Music Object instances that belonged to the group, so there may be a noticeable volume change for those instances at the time that a volume group is destroyed.

Removing all of the members of a volume group has the same effect as destroying the volume group. For instance, a volume group that was set up with the code...

Music.addVolumeGroupMembers (
   'My Volume Group',
   new Array (
      myMusicObject1,
      myMusicObject2,
      myMusicObject3,
      myMusicObject4,
      myMusicObject5
   )
);

...could be destroyed with the code...

Music.removeVolumeGroupMembers (
   'My Volume Group',
   new Array (
      myMusicObject1,
      myMusicObject2,
      myMusicObject3,
      myMusicObject4,
      myMusicObject5
   )
);

...or the code...

Music.destroyVolumeGroup ('My Volume Group');

SPECIAL VALUES
VARIATIONS
NOTES
 Music.fadeGroupVolume

 
 CATEGORY   Static Method 
 MODULE   Music Object Extension - Group Volume 
 Min. Player Version   1.0.0 
 

The Music.fadeGroupVolume static method lets you perform a volume fade on the specified volume group.

SYNTAX    Music.fadeGroupVolume (
    GroupNameSTR ,
    StartVolume0to100 ,
    EndVolume0to100 ,
    FadeTimeMsINT ,
    FadeEndCallbackFunctionorJavaScriptSTR ,
)

RETURN VALUE    FadeOBJ

SPECIAL VALUES
VARIATIONS
 Music.fadePageVolume

 
 CATEGORY   Static Method 
 MODULE   Music Object Extension - Group Volume 
 Min. Player Version   1.0.0 
 

The Music.fadePageVolume static method lets you perform a fade of the page's volume, effectively fading all Music Object instances in the page.

SYNTAX    Music.fadePageVolume (
    StartVolume0to100 ,
    EndVolume0to100 ,
    FadeTimeMsINT ,
    FadeEndCallbackFunctionorJavaScriptSTR ,
)

RETURN VALUE    FadeOBJ

The Music.fadePageVolume method essentially performs a fade for the special volume group "Page Volume", which contains all Music Object instances in a page.

SPECIAL VALUES
VARIATIONS
NOTES
 Music.getGroupVolume

 
 CATEGORY   Static Method 
 MODULE   Music Object Extension - Group Volume 
 Min. Player Version   1.0.0 
 

The Music.getGroupVolume static method returns an integer value, indicating the volume level for the specified volume group.

SYNTAX    Music.getGroupVolume ( GroupNameSTR )

RETURN VALUE    Volume0to100

SPECIAL VALUES
VARIATIONS
NOTES
 Music.getPageVolume

 
 CATEGORY   Static Method 
 MODULE   Music Object Extension - Group Volume 
 Min. Player Version   1.0.0 
 

The Music.getPageVolume static method returns an integer value, indicating the overall volume level for the page.

SYNTAX    Music.getPageVolume ( )

RETURN VALUE    Volume0to100

The Music.getPageVolume method essentially queries the volume level for the special volume group "Page Volume", which contains all Music Object instances in a page.

NOTES
 Music.removeVolumeGroupMembers

 
 CATEGORY   Static Method 
 MODULE   Music Object Extension - Group Volume 
 Min. Player Version   1.0.0 
 

The Music.removeVolumeGroupMembers static method lets you remove the specified Music Object instance(s) from the specified volume group.

SYNTAX    Music.removeVolumeGroupMembers (
   GroupNameSTR ,
   GroupMembersARRAYorOBJ
)

Multiple Music Object instances can be removed from a group - one at a time - by specifying the Music Object instance references in multiple calls to the Music.removeVolumeGroupMembers method, as in the code...

Music.removeVolumeGroupMembers ('My Volume Group',myMusicObject1);
Music.removeVolumeGroupMembers ('My Volume Group',myMusicObject2);
Music.removeVolumeGroupMembers ('My Volume Group',myMusicObject3);
Music.removeVolumeGroupMembers ('My Volume Group',myMusicObject4);
Music.removeVolumeGroupMembers ('My Volume Group',myMusicObject5);

Alternatively, by specifying an array for the GroupMembersARRAYorOBJ parameter, all the instances can be removed in just one statement. A temporary array can be created inside the call to the Music.removeVolumeGroupMembers method to contain all the Music Object instances, as in the code...

Music.removeVolumeGroupMembers (
   'My Volume Group',
   new Array (
      myMusicObject1,
      myMusicObject2,
      myMusicObject3,
      myMusicObject4,
      myMusicObject5
   )
);

When removing members from a volume group, it doesn't matter in what order the members were originally added, over how many separate statements the members were added, or whether the members were added using arrays or single object references.

So, for example, the members added to the volume group "My Volume Group" using the code...

Music.addVolumeGroupMembers ('My Volume Group',myMusicObject2);

Music.addVolumeGroupMembers (
   'My Volume Group',
   new Array (
      myMusicObject5,
      myMusicObject3,
      myMusicObject4
   )
);

Music.addVolumeGroupMembers ('My Volume Group',myMusicObject1);

...could all be removed from the volume group "My Volume Group" using the single statement...

Music.removeVolumeGroupMembers (
   'My Volume Group',
   new Array (
      myMusicObject1,
      myMusicObject2,
      myMusicObject3,
      myMusicObject4,
      myMusicObject5
   )
);

Removing all of the members of a volume group has the same effect as destroying the volume group. For instance, a volume group that was set up with the code...

Music.addVolumeGroupMembers (
   'My Volume Group',
   new Array (
      myMusicObject1,
      myMusicObject2,
      myMusicObject3,
      myMusicObject4,
      myMusicObject5
   )
);

...could be destroyed with the code...

Music.removeVolumeGroupMembers (
   'My Volume Group',
   new Array (
      myMusicObject1,
      myMusicObject2,
      myMusicObject3,
      myMusicObject4,
      myMusicObject5
   )
);

...or the code...

Music.destroyVolumeGroup ('My Volume Group');

SPECIAL VALUES
VARIATIONS
NOTES
 Music.setGroupVolume

 
 CATEGORY   Static Method 
 MODULE   Music Object Extension - Group Volume 
 Min. Player Version   1.0.0 
 

The Music.setGroupVolume static method lets you set the volume level for the specified volume group.

SYNTAX    Music.setGroupVolume ( GroupNameSTR , Volume0to100 )

SPECIAL VALUES
VARIATIONS
NOTES
 Music.setPageVolume

 
 CATEGORY   Static Method 
 MODULE   Music Object Extension - Group Volume 
 Min. Player Version   1.0.0 
 

The Music.setPageVolume static method lets you set the overall page volume, affecting all Music Object instances in the page.

SYNTAX    Music.setPageVolume ( Volume0to100 )

The Music.setPageVolume method essentially sets the volume level for the special volume group "Page Volume", which contains all Music Object instances in a page.

VARIATIONS
NOTES